package com.lenovo.testreport.gray.web.languageTest.controller;

import com.lenovo.testreport.general.service.GeneralCaseService;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author CJF
 * @date 2018/12
 * 操作CASE表
 */
@Controller
@RequestMapping("/gray/web")
public class GrayWebCaseController {

    @Autowired
    @Qualifier("GrayWebLanguageEnglishPropertiesCaseService")
    //接口有多个实现时，使用@Qualifier注解指定应该使用哪一个实现类，否则@Autowired会报错
    private GeneralCaseService grayWebLanguageEnglishPropertiesCaseService;

    @Autowired
    @Qualifier("GrayWebLanguageTraditionalPropertiesCaseService")
    private GeneralCaseService grayWebLanguageTraditionalPropertiesCaseService;


    @RequestMapping("/language/english/properties/FindByRid")
    //@ResponseBody作用是将方法返回的对象写入到response对象的body区（返回体）里
    public @ResponseBody
    List language_en_properties_FindByRid(HttpServletRequest request) {

        int id = Integer.valueOf(request.getParameter("rid"));
        return grayWebLanguageEnglishPropertiesCaseService.findByRid(request.getParameter("tablename"), id);
    }

    @RequestMapping("/language/tw/properties/FindByRid")
    public @ResponseBody
    List language_tw_properties_FindByRid(HttpServletRequest request) {

        int id = Integer.valueOf(request.getParameter("rid"));
        return grayWebLanguageTraditionalPropertiesCaseService.findByRid(request.getParameter("tablename"), id);
    }
}
